﻿using CommonBase;
using EnvControlLib;
using InteractiveWhiteboardManagement.Base.ViewModels;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.Regions;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Windows;

namespace InteractiveWhiteboardManagement.ViewModels
{
    /// <summary>
    /// 产品注册
    /// </summary>
    public class ViewModel_Registration : WorkspaceViewModel
    {
        #region 变量

        private DelegateCommand _cmdApply, _cmdCancel, _cmdCopy;

        #endregion

        #region 构造函数

        public ViewModel_Registration(IRegionManager regionManager)
        {
            if (regionManager == null)
                return;

            base.BaseRegionManager = regionManager;
            base.ViewName = InteractiveWhiteboardManagement.Base.Common.ViewNames.InteractiveWhiteboardManagement_Registration;
            base.HeaderTitle = "产品注册";
            base.HeaderImageSource = string.Format(ConstantString.IMAGE_URL, "Key");
            base.IsShowCloseButton = Visibility.Visible;
        }

        #endregion

        #region 属性

        /// <summary>
        /// 确认
        /// </summary>
        [Display(GroupName = "DelegateCommand")]
        public DelegateCommand Cmd_Apply
        {
            get
            {
                if (_cmdApply == null)
                {
                    _cmdApply = new DelegateCommand(_apply, _canApply);
                }
                return _cmdApply;
            }
        }

        /// <summary>
        /// 取消
        /// </summary>
        [Display(GroupName = "DelegateCommand")]
        public DelegateCommand Cmd_Cancel
        {
            get
            {
                if (_cmdCancel == null)
                {
                    _cmdCancel = new DelegateCommand(_cancel, _canCancel);
                }
                return _cmdCancel;
            }
        }

        /// <summary>
        /// 复制
        /// </summary>
        [Display(GroupName = "DelegateCommand")]
        public DelegateCommand Cmd_Copy
        {
            get
            {
                if (_cmdCopy == null)
                {
                    _cmdCopy = new DelegateCommand(_copy, _canCopy);
                }
                return _cmdCopy;
            }
        }

        #endregion

        #region 方法

        #region DelegateCommand

        private bool _canApply()
        {
            return true;
        }

        private bool _canCancel()
        {
            return true;
        }

        private bool _canCopy()
        {
            return true;
        }


        /// <summary>
        /// 确认
        /// </summary>
        private void _apply()
        {


            AutoCloseNoticeWindow.Show("保存成功，重启程序后生效！", false);
            this.CloseCommand.Execute(null);
        }

        /// <summary>
        /// 取消
        /// </summary>
        private void _cancel()
        {
            

            this.CloseCommand.Execute(null);
        }

        /// <summary>
        /// 复制
        /// </summary>
        private void _copy()
        {
            
        }

        #endregion

        #endregion
    }
}
